var gridcomm = require('./gridcomm.js');
var webserver = require('./httpserver.js');

var g_data = {
	grids : {},
	nodes : {},
	workers : {},
};

gridcomm()
	.on('event', function(channel, remote, data){
		switch(channel){
			case "grid":
				processGridInfo(remote, data);
				break;
		}
	})
	.connect();

webserver()
	.map("data", function(){
		return JSON.stringify(g_data);
	})
	.connect();
	

// Events
function processGridInfo(remote, data){
	g_data.grids[data.Id] = data;
}
